<?php


namespace app\admin\model;


class Registered extends BaseModel
{
    # 隐藏记录
    public function hideOne($id)
    {
        $list = self::get($id);
        $status = $list->status;
        $status_code = null;
        if($status == 0){
            $list->status = 1;
            $status_code = 1;
        }elseif($status ==1){
            $list->status = 0;
            $status_code = 0;
        }$list->save();
        return $status_code;
    }

    # 获取手机号码的贷款状态
    public function getLoanStatusAttr($value, $data)
    {
        if($data['type'] == 'd'){
            $arr = config('status.d');
            return $arr[$value];
        }
        if($data['type'] == 'f'){
            $arr = config('status.f');
            return $arr[$value];
        }
    }
    # 删除选择id的记录
    public function delCheck($ids_arr)
    {
        return self::where('id','in', $ids_arr)
            ->delete();
    }

    # 获取所有未借款的借款
    public function getAllData()
    {
        return self::where('id', 'in', [config('status.no')])
            ->select()
            ->toArray();
    }

    # 贷款金额状态
    public function getUserLoanMoneyAttr($value)
    {
        if($value == 20 || $value == 19 || $value == 21 || $value == null){
            return 0;
        }else{
            return $value;
        }
    }

    # 放款金额状态
    public function getUserLoanGetMoneyAttr($value)
    {
        if($value == 20 || $value == 19 || $value == 21 || $value == null){
            return 0;
        }else{
            return $value;
        }
    }
}